#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def show_more(text, numlines=15):
    """分割字符串或文本并交互地进行分页"""
    # splitlines函数可以将字符串切分成不包含'\n'的列表
    lines = text.splitlines()
    while lines:
        chunk = lines[:numlines]
        lines = lines[numlines:]
        for line in chunk:
            print(line)
        if lines and input('Show more?') not in ['y', 'Y']:
            break


if __name__ == '__main__':
    import sys
    text = sys.__doc__
    show_more(text, 20)
